home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / Libraries / MenuSharing / menusharing.p < prev   
Text File  |  1997-01-26  |  3KB  |  93 lines

  1.  
  2. { © copyright 1991-93 UserLand Software, Inc. All RIghts Reserved.}
  3. { Pascal Conversion by Peter N Lewis <peter@stairways.com.au> }
  4.  
  5. unit MenuSharing;
  6.  
  7. interface
  8.  
  9.     uses
  10.         AppleEvents,Components,Menus, MyCallProc;
  11.     
  12. {$PUSH}
  13. {$ALIGN MAC68K}
  14.  
  15.     type
  16.         tysharedmenurecord = record    { must match scripting system record structure }
  17.             idmenu:SInt16;
  18.             flags:SInt16;
  19.             hmenu:MenuHandle;
  20.         end;
  21.  
  22.     const
  23.         flhierarchic_mask = $0001;
  24.         flhierarchic_bit = 0;
  25.         flinserted_mask = $0002;
  26.         flinserted_bit = 1;
  27.  
  28.     type
  29.         tymenuarray = array[0..0] of tysharedmenurecord;
  30.         ptrmenuarray = ^tymenuarray;
  31.         hdlmenuarray = ^ptrmenuarray;
  32.  
  33.     type
  34.         tyMSerrordialog = ProcPtr; { procedure tyMSerrordialog(var theString:Str255); }
  35.         tyMSeventfilter = ProcPtr; { procedure tyMSeventfilter(var theEvent:EventRecord); }
  36.         tyMSmenusinstaller = ProcPtr; { procedure tyMSmenusinstaller(hndl:hdlmenuarray); }
  37.         
  38.     type
  39.         tyMSglobals = record {Menu Sharing globals, all in one struct}
  40.             serverid:OSType;{identifier for shared menu server}
  41.             clientid:OSType; {id of this application}
  42.             hsharedmenus:hdlmenuarray; {data structure that holds shared menus}
  43.             fldirtysharedmenus:Boolean; {if true, menus are reloaded next time app comes to front}
  44.             flscriptcancelled:Boolean; {set true by calling CancelSharedScript}
  45.             flscriptrunning:Boolean; {true if a script is currently running}
  46.             flinitialized:Boolean; {true if InitSharedMenus was successful}
  47.             idscript:longint; {the server's id for the currently running script, makes it easy to kill it}
  48.             menuserver:ComponentInstance; {3.0} 
  49.             serverversion: longint; { 4.1 }
  50.             scripterrorcallback:tyMSerrordialog; {3.0}
  51.             eventfiltercallback:tyMSeventfilter; {3.0}
  52.             menusinsertercallback: tyMSmenusinstaller; { 4.1 }
  53.             menusremovercallback: tyMSmenusinstaller; { 4.1 }
  54.         end;
  55.  
  56.     var
  57.     {$J+}
  58.         MSglobals:tyMSglobals; {menu sharing globals}
  59.  
  60. {basic Menu Sharing routines}
  61.  
  62.     function InitSharedMenus (msed:tyMSerrordialog; msef:tyMSeventfilter):Boolean;
  63.  
  64.     function SharedMenuHit (menu,item:integer):Boolean;
  65.     
  66.     function SharedScriptRunning:Boolean;
  67.     
  68.     function CancelSharedScript:Boolean;
  69.     
  70.     function CheckSharedMenus (menu:integer):Boolean;
  71.     
  72.     function SharedScriptCancelled (var event,reply:AppleEvent):Boolean;
  73.     
  74.  
  75. {special-purpose routines}
  76.  
  77.     function DisposeSharedMenus:Boolean;
  78.  
  79.     function IsSharedMenu (menu:integer):Boolean;
  80.     
  81.     function EnableSharedMenus (enable:Boolean):Boolean;
  82.     
  83.     function RunSharedMenuItem (menu,item:integer):Boolean;
  84.     
  85.     function SetMenusInserterCallback( installer: tyMSmenusinstaller): Boolean;
  86.     
  87.     function SetMenusRemoverCallback( remover: tyMSmenusinstaller): Boolean;
  88.     
  89. {$ALIGN RESET}
  90. {$POP}
  91.  
  92. end.    
  93.